//compiler-depended options & defines (MSVC, GCC)
//$Id: compiler_defines.h 163 2009-09-10 11:38:53Z Oleg.Bulychov $
#pragma once
#ifndef COMPILER_DEFINES_H
#define COMPILER_DEFINES_H

#if defined(__INTEL_COMPILER)

#define ALIGN__(x)    __declspec(align(x))
#define DEBUG_BREAK__ 0
#define NO_THROW_()

//:int64_t, uint64_t
//#include <inttypes.h>
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
#elif defined(_MSC_VER)

#if (_MSC_VER >= 1400)

//:no exceptions
#pragma warning( disable : 4530 )
//__________________________________________________________________________________
//nameless structs
#pragma warning( disable : 4201 )
//__________________________________________________________________________________
//bit fields
#pragma warning( disable : 4214 )
//__________________________________________________________________________________
//unused params
#pragma warning( disable : 4100 )
//__________________________________________________________________________________
#ifdef _DEBUG
//unreferenced vars
#pragma warning( disable : 4101 )
//__________________________________________________________________________________
//unreferenced vars
#pragma warning( disable : 4189 )
#endif
//__________________________________________________________________________________
//copy constructor could not be generated
#pragma warning( disable : 4511 )
//__________________________________________________________________________________
//assignment operator could not be generated
#pragma warning( disable : 4512 )
//__________________________________________________________________________________
//unused inline function
#pragma warning( disable : 4514 )
//__________________________________________________________________________________
//unused static function
#pragma warning( disable : 4505 )
//__________________________________________________________________________________
//copy constructor could not be generated because a base class copy constructor is inaccessible
#pragma warning( disable : 4625 )
//__________________________________________________________________________________
//assignment operator could not be generated because a base class assignment operator is inaccessible
#pragma warning( disable : 4626 )
//__________________________________________________________________________________
//in stl: template functions cannot be used for copy-assignment or copy-construction
#pragma warning( disable : 4217 )
//__________________________________________________________________________________
//default constructor could not be generated because a base class default constructor is inaccessible
#pragma warning( disable : 4623 )
//__________________________________________________________________________________
//not defined preprocessor macro in #if (MACRO)
#pragma warning( disable : 4668 )
//__________________________________________________________________________________
//performed inlining on the given (noinline) function ("any suitable" on)
#pragma warning( disable : 4711 )
//__________________________________________________________________________________
//converting '()' to '(void)
#pragma warning( disable : 4255 )
//__________________________________________________________________________________
//class template specialization was not is defined before it was used in a return type
#pragma warning( disable : 4686 )
//__________________________________________________________________________________
//behavior change: 'function template' is called instead of 'function'
#pragma warning( disable : 4347 )
//__________________________________________________________________________________
//new standard feature - Koenig lookup
#pragma warning( disable : 4675 )
//__________________________________________________________________________________
//constructor could not be generated
#pragma warning( disable : 4510 )
#pragma warning( disable : 4610 )
//__________________________________________________________________________________
//forming a pointer-to-member requires explicit use of the address-of operator ('&') and a qualified name
#pragma warning( disable : 4529 )
//__________________________________________________________________________________
//this in constructor init list
#pragma warning( disable : 4355 )
//__________________________________________________________________________________
//__________________________________________________________________________________
//Studio 2005: deprecated CRT functions
#pragma warning(disable : 4996)
//__________________________________________________________________________________
//nonstandard extension used: override, sealed
//#pragma warning(disable: 4481)
//__________________________________________________________________________________
//structure was padded due to __declspec(align())
#pragma warning(disable: 4324)
//__________________________________________________________________________________
#endif
//__________________________________________________________________________________
//TARGET platform: win 2000
#if !defined(WINVER)
#define WINVER         0x0500
#endif
#if !defined(_WIN32_WINNT)
#define _WIN32_WINNT   0x0500
#endif
#if !defined(_WIN32_WINDOWS)
#define _WIN32_WINDOWS 0x0500
#endif
#if !defined(_WIN32_IE)
#define _WIN32_IE      0x0500
#endif
#if !defined(WINNT)
#define WINNT
#endif

typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;

#define ALIGN__(x)    __declspec(align(x))
//TODO fix me: __alignof__ mey be 0 for when x has not yet been instantiated
//#define ALIGN_OF__(x) __alignof(x)
#define DEBUG_BREAK__ __debugbreak()
//:in msvc throw() is non-standard optimization!!! :-/
#define NO_THROW_()   throw()

//:supress dangerous macros
#define NOMINMAX

//__________________________________________________________________________________
#ifdef _DEBUG 
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
#elif defined(__GNUC__)

#define ALIGN__(x)    __attribute__ ((aligned (x)))
//TODO fix me: __alignof__ mey be 0 for when x has not yet been instantiated
//#define ALIGN_OF__(x) __alignof__(x)
#define DEBUG_BREAK__ 0
//:TODO review: here is __attribute__(nothrow) in some gcc versions...
#define NO_THROW_()

//:int64_t, uint64_t
//#include <inttypes.h>
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
#else

#error fix me: add new compiler stuff
//:NOTE: some compilers may define __GNUC__ for compatibility, so move them up

#endif
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________

typedef unsigned char byte_t;
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//:ROUND2 rounds a number up to a power of 2
#define ROUND2(n, pow2)    (((n) + (pow2) - 1) & ~((pow2) - 1))
//__________________________________________________________________________________
#define COMPILETIME_CHECK(expr, msg)\
typedef char Error_##msg[1][(expr)]
//__________________________________________________________________________________
//__________________________________________________________________________________
extern void My_Assert(char const* szExpression, char const* szFile, unsigned nLine) NO_THROW_();
#define VERIFY_(expression) (void)( (!!(expression)) || (DEBUG_BREAK__, My_Assert(#expression, __FILE__, __LINE__), 0) )
#if defined(DEBUG) || defined(_DEBUG)
#define ASSERT_(expression) (void)( (!!(expression)) || (DEBUG_BREAK__, My_Assert(#expression, __FILE__, __LINE__), 0) )
#else
#define ASSERT_(expression) ((void)0)
#endif
//__________________________________________________________________________________
//__________________________________________________________________________________
/* From google code:
A macro to disallow the evil copy constructor and operator= functions
This should be used in the private: declarations for a class
*/
#define DISALLOW_COPY_AND_ASSIGN(TypeName)    \
  TypeName(TypeName const&);                  \
  TypeName& operator=(TypeName const&)
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
#define STRINGIZE_A(text) #text
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________
//__________________________________________________________________________________

#endif
//EOF!
